package com.xneure.utils.bean;

public class Caller implements Cloneable{
	private int lineNumber;
	private String className;
	private String methodName;

	public Caller(StackTraceElement ste){
		className = ste.getClassName();
		lineNumber = ste.getLineNumber();
		methodName = ste.getMethodName();
		if(null != methodName){
			if(methodName.equals("<init>")){
				methodName = "全局变量/构造方法";
			}else if(methodName.equals("<clinit>")){
				methodName = "静态全局变量";
			}
		}
	}

	public int getLineNumber(){
		return lineNumber;
	}

	public void setLineNumber(int lineNumber){
		this.lineNumber = lineNumber;
	}

	public String getClassName(){
		return className;
	}

	public void setClassName(String className){
		this.className = className;
	}

	public String getMethodName(){
		return methodName;
	}

	public void setMethodName(String methodName){
		this.methodName = methodName;
	}

	@Override
	public String toString(){
		StringBuilder sb = new StringBuilder(50);
		sb.append(className).append(".").append(methodName).append(" -> ").append(lineNumber).append(" 行");
		return sb.toString();
	}

	@Override
	public Caller clone(){
		try{
			return (Caller)super.clone();
		}catch(CloneNotSupportedException e){
			return null;
		}
	}
}
